/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Presentation;

import BLO.QuydinhBLO;
import DAO.Result;
import DTO.QUYDINH;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author LUCKYSTARS
 */
public class ThaydoiQuydinh extends javax.swing.JPanel {
    QuydinhBLO qdBLO= new QuydinhBLO();

    public ThaydoiQuydinh() {
        
        initComponents();
        QUYDINH ttt= new QUYDINH();
        QUYDINH ttd= new QUYDINH();
        QUYDINH cttt= new QUYDINH();
        QUYDINH cttd= new QUYDINH();
        
      ResultSet rs=qdBLO.Getdata();
        try {
           rs.next();
            ttt.setMats(rs.getString(1).trim());
            ttt.setGiatri(Integer.parseInt(rs.getString(3).trim()));
            ttt.setTinhtrang(Integer.parseInt(rs.getString(4)));
             rs.next();
            ttd.setMats(rs.getString(1).trim());
            ttd.setGiatri(Integer.parseInt(rs.getString(3).trim()));
            ttd.setTinhtrang(Integer.parseInt(rs.getString(4)));
              rs.next();
            cttt.setMats(rs.getString(1).trim());
            cttt.setGiatri(Integer.parseInt(rs.getString(3).trim()));
            cttt.setTinhtrang(Integer.parseInt(rs.getString(4)));
              rs.next();
            cttd.setMats(rs.getString(1).trim());
            cttd.setGiatri(Integer.parseInt(rs.getString(3).trim()));
            cttd.setTinhtrang(Integer.parseInt(rs.getString(4)));
            
            if(ttt.getTinhtrang()!=0)
                chkTTT.setSelected(true);
            if(ttd.getTinhtrang()!=0)
                chkTTD.setSelected(true);
            if(cttt.getTinhtrang()!=0)
                chkCTTT.setSelected(true);
            if(cttd.getTinhtrang()!=0)
                chkCTTD.setSelected(true);
            
            txtTuoiTT.setText(Integer.toString(ttt.getGiatri()));
             txtTuoiTD.setText(Integer.toString(ttd.getGiatri()));
              txtCTTT.setText(Integer.toString(cttt.getGiatri()));
               txtCTTD.setText(Integer.toString(cttd.getGiatri()));
            
 
            
        } catch (SQLException ex) {
            Logger.getLogger(ThaydoiQuydinh.class.getName()).log(Level.SEVERE, null, ex);
        }
      
      
        
             
        
        
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        chkTTT = new javax.swing.JCheckBox();
        chkTTD = new javax.swing.JCheckBox();
        chkCTTT = new javax.swing.JCheckBox();
        chkCTTD = new javax.swing.JCheckBox();
        txtTuoiTT = new javax.swing.JTextField();
        txtTuoiTD = new javax.swing.JTextField();
        txtCTTT = new javax.swing.JTextField();
        txtCTTD = new javax.swing.JTextField();
        btnTTT = new javax.swing.JButton();
        btnTTD = new javax.swing.JButton();
        btnCTTT = new javax.swing.JButton();
        btnCTTD = new javax.swing.JButton();

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel1.setText("THAY ĐỔI QUY ĐỊNH");

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        chkTTT.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        chkTTT.setText("Tuổi tối thiểu:");

        chkTTD.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        chkTTD.setText("Tuổi tối đa:");

        chkCTTT.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        chkCTTT.setText("Cầu thủ tối thiểu:");

        chkCTTD.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        chkCTTD.setText("Cầu thủ tối đa:");

        txtTuoiTT.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        txtTuoiTD.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        txtCTTT.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        txtCTTD.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        btnTTT.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        btnTTT.setText("Thay đổi");
        btnTTT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTTTActionPerformed(evt);
            }
        });

        btnTTD.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        btnTTD.setText("Thay đổi");
        btnTTD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTTDActionPerformed(evt);
            }
        });

        btnCTTT.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        btnCTTT.setText("Thay đổi");
        btnCTTT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCTTTActionPerformed(evt);
            }
        });

        btnCTTD.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        btnCTTD.setText("Thay đổi");
        btnCTTD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCTTDActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(76, 76, 76)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chkTTD)
                    .addComponent(chkTTT)
                    .addComponent(chkCTTT)
                    .addComponent(chkCTTD))
                .addGap(49, 49, 49)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtTuoiTT)
                    .addComponent(txtTuoiTD)
                    .addComponent(txtCTTT)
                    .addComponent(txtCTTD, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(47, 47, 47)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnTTT)
                    .addComponent(btnTTD)
                    .addComponent(btnCTTT)
                    .addComponent(btnCTTD))
                .addContainerGap(39, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chkTTT)
                    .addComponent(txtTuoiTT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnTTT))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chkTTD)
                    .addComponent(txtTuoiTD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnTTD))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addComponent(txtCTTD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtCTTT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnCTTT)
                            .addComponent(chkCTTT))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnCTTD)
                            .addComponent(chkCTTD))))
                .addContainerGap(80, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(179, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(262, 262, 262))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(155, 155, 155))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(169, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnTTTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTTTActionPerformed
        // TODO add your handling code here:
        QUYDINH qdDTO= new QUYDINH();
        qdDTO.setGiatri(Integer.parseInt(txtTuoiTT.getText().trim()));
        qdDTO.setMats("TuoiTT");
         if (chkTTT.isSelected()==true)
	                qdDTO.setTinhtrang(1);
	            else
	                qdDTO.setTinhtrang(0);
         qdBLO.Update(qdDTO);
        
        
        
    }//GEN-LAST:event_btnTTTActionPerformed

    private void btnTTDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTTDActionPerformed

            QUYDINH qdDTO= new QUYDINH();
        qdDTO.setGiatri(Integer.parseInt(txtTuoiTD.getText().trim()));
        qdDTO.setMats("TuoiTD");
         if (chkTTD.isSelected()==true)
	                qdDTO.setTinhtrang(1);
	            else
	                qdDTO.setTinhtrang(0);
         qdBLO.Update(qdDTO);
        // TODO add your handling code here:
    }//GEN-LAST:event_btnTTDActionPerformed

    private void btnCTTTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCTTTActionPerformed

            QUYDINH qdDTO= new QUYDINH();
        qdDTO.setGiatri(Integer.parseInt(txtCTTT.getText().trim()));
        qdDTO.setMats("CTTT");
         if (chkCTTT.isSelected()==true)
	                qdDTO.setTinhtrang(1);
	            else
	                qdDTO.setTinhtrang(0);
         qdBLO.Update(qdDTO);
        // TODO add your handling code here:
    }//GEN-LAST:event_btnCTTTActionPerformed

    private void btnCTTDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCTTDActionPerformed

               QUYDINH qdDTO= new QUYDINH();
        qdDTO.setGiatri(Integer.parseInt(txtCTTD.getText().trim()));
        qdDTO.setMats("CTTD");
         if (chkCTTD.isSelected()==true)
	                qdDTO.setTinhtrang(1);
	            else
	                qdDTO.setTinhtrang(0);
         qdBLO.Update(qdDTO);
        // TODO add your handling code here:
    }//GEN-LAST:event_btnCTTDActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCTTD;
    private javax.swing.JButton btnCTTT;
    private javax.swing.JButton btnTTD;
    private javax.swing.JButton btnTTT;
    private javax.swing.JCheckBox chkCTTD;
    private javax.swing.JCheckBox chkCTTT;
    private javax.swing.JCheckBox chkTTD;
    private javax.swing.JCheckBox chkTTT;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField txtCTTD;
    private javax.swing.JTextField txtCTTT;
    private javax.swing.JTextField txtTuoiTD;
    private javax.swing.JTextField txtTuoiTT;
    // End of variables declaration//GEN-END:variables
}
